package com.itheimaoa.service.process;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import org.jbpm.api.Deployment;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.model.OpenExecution;
import org.jbpm.api.task.Assignable;
import org.jbpm.api.task.AssignmentHandler;
import org.jbpm.api.task.Task;

import com.itheimaoa.util.JDBCUtils;

public class MyAssignmentHandler implements AssignmentHandler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void assign(Assignable assignable, OpenExecution execution) throws Exception {
		Connection conn=JDBCUtils.getConnection();
		String jpql = " select eid from employee";
		Statement st = conn.createStatement();
		ResultSet rs = st.executeQuery(jpql);
		while(rs.next()){
			assignable.addCandidateUser(String.valueOf(rs.getInt("eid")));
		}
	}
}
